<!DOCTYPE html>
<html lang="zh" xmlns:th="http://www.thymeleaf.org" xmlns:shiro="http://www.pollix.at/thymeleaf/shiro">
<head>
    <th:block th:include="include :: header('回复列表')"/>
</head>
<body class="gray-bg">
<div class="container-div">
    <div class="row">
        <div class="col-sm-12 search-collapse">
            <form id="formId">
                <div class="select-list">
                    <ul>
                        <li>
                            <label>评论id：</label>
                            <input type="text" name="commentId"/>
                        </li>
                        <li>
                            <label>评论状态：</label>
                            <select name="status" th:with="type=${@dict.getType('comment_status')}">
                                <option value="">所有</option>
                                <option th:each="dict : ${type}" th:text="${dict.dictLabel}"
                                        th:value="${dict.dictValue}"></option>
                            </select>
                        </li>
                        <li>
                            <a class="btn btn-primary btn-rounded btn-sm" onclick="$.table.search()"><i
                                    class="fa fa-search"></i>&nbsp;搜索</a>
                            <a class="btn btn-warning btn-rounded btn-sm" onclick="$.form.reset()"><i
                                    class="fa fa-refresh"></i>&nbsp;重置</a>
                        </li>
                    </ul>
                </div>
            </form>
        </div>

        <div class="btn-group-sm" id="toolbar" role="group">
            <a class="btn btn-success" onclick="$.operate.add()" shiro:hasPermission="xsp:reply:add">
                <i class="fa fa-plus"></i> 添加
            </a>
            <a class="btn btn-primary single disabled" onclick="$.operate.edit()" shiro:hasPermission="xsp:reply:edit">
                <i class="fa fa-edit"></i> 修改
            </a>
            <a class="btn btn-warning multiple disabled"  data-toggle="modal" data-target="#checkAllModal" shiro:hasPermission="xsp:reply:edit">
                <i class="fa fa-calendar-check-o"></i> 批量审核
            </a>
            <a class="btn btn-danger multiple disabled" onclick="$.operate.removeAll()"
               shiro:hasPermission="xsp:reply:remove">
                <i class="fa fa-remove"></i> 删除
            </a>
            <div class="modal inmodal" id="checkAllModal" tabindex="-1" role="dialog" aria-hidden="true">
                <div class="modal-dialog modal-sm">
                    <div class="modal-content animated ">
                        <div class="modal-header">
                            <button type="button" class="close" data-dismiss="modal"><span aria-hidden="true">&times;</span><span class="sr-only">Close</span>
                            </button>
                            <h4 class="modal-title">批量审核</h4>
                        </div>
                        <div class="modal-body">
                            <div class="form-group">
                                <label>评论状态：</label>
                                <select id="checkStatus" th:with="type=${@dict.getType('comment_status')}" class="form-control">
                                    <option th:each="dict : ${type}" th:text="${dict.dictLabel}" th:value="${dict.dictValue}"></option>
                                </select>
                            </div>
                        </div>
                        <div class="modal-footer">
                            <button type="button" class="btn btn-white" data-dismiss="modal">关闭</button>
                            <button type="button" class="btn btn-primary" onclick="checkAll()">保存</button>
                        </div>
                    </div>
                </div>
            </div>
<!--            <a class="btn btn-warning" onclick="$.table.exportExcel()" shiro:hasPermission="xsp:reply:export">-->
<!--                <i class="fa fa-download"></i> 导出-->
<!--            </a>-->
        </div>
        <div class="col-sm-12 select-table table-striped">
            <table id="bootstrap-table"></table>
        </div>
    </div>
</div>
<th:block th:include="include :: footer"/>
<script th:inline="javascript">
    var editFlag = [[${@permission.hasPermi('xsp:reply:edit')}]];
    var removeFlag = [[${@permission.hasPermi('xsp:reply:remove')}]];
    var statusDatas = [[${@dict.getType('comment_status')}]];
    var prefix = ctx + "xsp/reply";

    $(function () {
        var options = {
            url: prefix + "/list",
            createUrl: prefix + "/add",
            updateUrl: prefix + "/edit/{id}",
            checkUrl: prefix + "/check/{id}",
            checkAllUrl: prefix + "/checkAll",
            removeUrl: prefix + "/remove",
            exportUrl: prefix + "/export",
            modalName: "回复",
            sortName: " status asc,id ",
            columns: [{
                checkbox: true
            },
                {
                    field: 'id',
                    title: '',
                    visible: false
                },
                {
                    field: 'commentId',
                    title: '评论id'
                },
                {
                    field: 'replyType',
                    title: '回复类型',
                    formatter: function (value, row, index) {
                        if (value == 0) {
                            return "<span class='badge badge-primary'>普通</span>";
                        } else {
                            return "<span class='badge label-danger'>回复</span>";
                        }
                    }
                },
                {
                    field: 'replyId',
                    title: '回复目标'
                },
                {
                    field: 'content',
                    title: '回复内容',
                    formatter:function (value,row,index) {
                       return  $.table.textSubstringView(value,10);
                    }
                },
                {
                    field: 'toUid',
                    title: '回复目标id'
                },
                {
                    field: 'fromUid',
                    title: '回复用户id'
                },
                {
                    field: 'fromThumbImg',
                    title: '回复者的头像',
                    formatter: function (value, row, index) {
                        return $.table.imageView(value);
                    }
                },
                {
                    field: 'fromNickname',
                    title: '回复者的昵称'
                },
                {
                    field: 'toNickname',
                    title: '冗余对象昵称'
                },
                {
                    field: 'isAuthor',
                    title: '管理员回复',
                    formatter: function (value, row, index) {
                        if (value == 0) {
                            return "<span class='badge badge-primary'>否</span>";
                        } else {
                            return "<span class='badge label-danger'>是</span>";
                        }
                    }
                },
                {
                    field: 'status',
                    title: '评论状态',
                    formatter: function (value, row, index) {
                        return $.table.selectDictLabel(statusDatas, value);
                    }
                },
                {
                    title: '操作',
                    align: 'center',
                    formatter: function (value, row, index) {
                        var actions = [];
                        actions.push('<a class="btn btn-warning btn-xs ' + editFlag + '" href="javascript:void(0)" onclick="$.operate.check(\'' + row.id + '\')"><i class="fa fa-calendar-check-o"></i>审核</a> ');
                        actions.push('<a class="btn btn-success btn-xs ' + editFlag + '" href="javascript:void(0)" onclick="$.operate.edit(\'' + row.id + '\')"><i class="fa fa-edit"></i>编辑</a> ');
                        actions.push('<a class="btn btn-danger btn-xs ' + removeFlag + '" href="javascript:void(0)" onclick="$.operate.remove(\'' + row.id + '\')"><i class="fa fa-remove"></i>删除</a>');
                        return actions.join('');
                    }
                }]
        };
        $.table.init(options);
    });
    function checkAll() {
        table.set();
        var rows = $.common.isEmpty(table.options.uniqueId) ? $.table.selectFirstColumns() : $.table.selectColumns(table.options.uniqueId);
        if (rows.length == 0) {
            $.modal.alertWarning("请至少选择一条记录");
            return;
        }
        var status=$("#checkStatus").val();
        $.operate.checkAll(status);
    }
</script>
</body>
</html>